import React, {Component} from 'react';
import {
  Badge,
  Card,
  NoticeBar,
  Button,
  Scroller,
  Popup,
  Group,
  Field,
  Toast,
  NumberPicker,
  CheckboxField,
  SelectField,
  SwitchField,
  RadioField
} from 'saltui';
import $ from 'jquery'
// <InputRadio options onChange value>
export default class InputRadio extends React.Component {

  constructor(props) {
    super(props);
    let that = this;
    let options = this.props.options;

    this.props.options.map(function (option, index) {

      if (option.value == that.props.value) {
        options[index]['checked'] = true;
      }
    })
    console.info( that.props.value);
    console.info(options);
    this.state = {
      options:options
    };


  }

  render() {
    console.info(this.state.options);
    let that =this;
    const radioFieldProps1 = {
      data: this.state.options,
      onChange(value, index, data) {
        that.props.onChange(value, index, data);
      },
      groupListArgument: {
        lineIndent: 15,
        itemIndent: 15,
      },
    };
    return (
      <RadioField {...radioFieldProps1} mode="popup" label="请选择类型" />
    );
  }

}
